﻿@model List<QizSession>
@{
    ViewBag.Title = "随访档案";
    //var UserIDStr = ViewBag.Recuper.UserID.ToString();
}
@using (Ajax.BeginForm("RecuperReport", new { IsView = false }, new AjaxOptions { HttpMethod = "Post", LoadingElementId = "OnLoadingSpan", UpdateTargetId = "main", OnFailure = "OnSiteError" }))
{<p>
    <fieldset>
        <legend>
            <div class="catalog-title">
                随访档案查询</div>
        </legend>随访单名称： @Html.DropDownList("QizSubjectID", new SelectList(ViewBag.Subjects, "ID", "Title", ViewBag.Subject))
        @Html.Hidden("pidx", 0, new { id = "qspidx" })
        @if (ViewBag.Flag == "Doctor")
        {
            Recuper tmpval=null;
            @:随访者： @Html.TextBox("RecuperName", (tmpval=ViewBag.Recuper)==null?string.Empty:tmpval.User.UserName)
        }
        @if (ViewBag.Recupers != null)
        { 
          @:入院时间： @Html.DropDownList("EnHospDay", new SelectList(ViewBag.Recupers, "EnHospDay", "EnHospDay", ViewBag.Recuper))
   
        }

        @Helpers.SubmitButton("查询", "qssubmit")

        <div>
    

        </div>
    </fieldset>
    </p>
}
@if (null == Model)
{
    
    <div>
        @Helpers.Shadowbox(
        @<table class="width">
            <tr>
                <th>
                    没有任何查询，请选择常规随访和患者查询。
                </th>
            </tr>
        </table>

    )
    </div>
}
else
{
    <div>
        @Helpers.Shadowbox(
        @<table class="width">
            <tr>
                <th>
                    随访单名称: @ViewBag.Subject.Title
                </th>
                <th>
                  填报人: @ViewBag.Recuper.User.UserName
                </th>
                <th>
                    开始时间: @ViewBag.StartTime
                </th>
            </tr>
        </table>

    )
    </div>
    <div>
        <table class="width">
            <tr>
                <th>
                </th>
                <th>
                    趋势
                </th>
                <th>
                    随访指标项
                </th>
                @foreach (var item in Model)
                {
                    <th title="@item.Timemark.ToString("yyy-MM-dd HH:mm")">
                        @item.Timemark.ToString("yyy-MM-dd")
                    </th>
                }
            </tr>
            <tr>
                <td>
                </td>
                <td>
                </td>
                <td>
                </td>
                @foreach (var item in Model)
                {
                    <td>@item.SubmitSrc</td>
                }
            </tr>
            @{var showidx = 1;}
            @foreach (var item in ((QizSubject)ViewBag.Subject).QizSubjectDefines.Where(v => v.QizItem.Type != "207").OrderBy(v => v.SortIdx))
            {
                
                <tr class="tr-backColor@(showidx % 2)">
                    <td>
                        @(showidx++)
                        @*@item.SortIdx*@
                    </td>
                    <td>
                        @if (item.QizItem.TypeRef.OptionValue == "2")
                        {
                            @Html.ActionLink("趋势", "QizItemValueAnalysis", "Recuper", new { RecuperID = ViewBag.Recuper.RecuperID, SubjID = item.QizSubjectID, ItemID = item.QizItemID, _newpage = "true", IsView = true }, new { target = "_blank" })
                            
                        }
                        else if (item.QizItem.TypeRef.OptionValue == "4")
                        {
                            @Html.ActionLink("对比", "QizItemValueAnalysis", "Recuper", new { RecuperID = ViewBag.Recuper.RecuperID, SubjID = item.QizSubjectID, ItemID = item.QizItemID, _newpage = "true", IsView = true }, new { target = "_blank" })
                        }
                    </td>
                    <td title="@item.QizItem.Title">
                        @Html.FixStrSuffix(item.QizItem.Title, 8)
                    </td>
                    @foreach (var v in Model)
                    {
                        var detail = v.QizSessionDetails.FirstOrDefault(s => s.QizSubjectDefine.SortIdx == item.SortIdx);
                        if (detail != null)
                        {
                        <td title="@detail.UserValue">
                            @Html.FixStrSuffix(detail.UserValue, 8)
                        </td>   
                        }
                        else
                        {
                        <td>
                        </td> 
                        }
                    }
                </tr>
            }
        </table>
    </div>
    <div class="pagger">
        @if (ViewBag.PageIdx == 0)
        {
            <span>首页</span>
            <span>上一页</span>
        }
        else
        {
            <span>
                @Html.ActionLink("首页", "RecuperReport", new { qizSubjectID = ViewBag.Subject.ID, recuperID = ViewBag.RecuperID, pidx = 0 })
            </span>
            <span>
                @Html.ActionLink("上一页", "RecuperReport", new { qizSubjectID = ViewBag.Subject.ID, recuperID = ViewBag.RecuperID, pidx = ViewBag.PageIdx - 1 })
            </span>
        }
        @if (ViewBag.PageCount < 8)
        {
            for (int i = 0; i < ViewBag.PageCount; i++)
            {
                if (i != ViewBag.PageIdx)
                {
            <span>
                @Html.ActionLink((i + 1).ToString(), "RecuperReport", new { qizSubjectID = ViewBag.Subject.ID, recuperID = ViewBag.RecuperID, pidx = i + 1 })
            </span>
                }
                else
                { 
            <span>[@((i + 1).ToString())]</span>
                }
            }
        }
        else
        {
            if (ViewBag.PageIdx >= 3 && ViewBag.PageCount - ViewBag.PageIdx > 3)
            {
                for (int i = ViewBag.PageIdx - 3; i < ViewBag.PageIdx + 4; i++)
                {
                    if (i != ViewBag.PageIdx)
                    {
            <span>@Html.ActionLink((i + 1).ToString(), "RecuperReport", new { qizSubjectID = ViewBag.Subject.ID, recuperID = ViewBag.RecuperID, pidx = i + 1 })
            </span>
                    }
                    else
                    { 
            <span>[@((i + 1).ToString())]</span>
                    }
                }
            }
            else if (ViewBag.PageIdx < 3)
            {
                for (int i = 0; i < 7; i++)
                {
                    if (i != ViewBag.PageIdx)
                    {
            <span>@Html.ActionLink((i + 1).ToString(), "RecuperReport", new { qizSubjectID = ViewBag.Subject.ID, recuperID = ViewBag.RecuperID, pidx = i + 1 })
            </span>
                    }
                    else
                    { 
            <span>[@((i + 1).ToString())]</span>
                    }
                }
            }
            else if (ViewBag.PageCount - ViewBag.PageIdx <= 3)
            {
                for (int i = ViewBag.PageCount - 6; i < ViewBag.PageCount + 1; i++)
                {
                    if (i != ViewBag.PageIdx + 1)
                    {
            <span>@Html.ActionLink((i).ToString(), "RecuperReport", new { qizSubjectID = ViewBag.Subject.ID, recuperID = ViewBag.RecuperID, pidx = i })
            </span>
                    }
                    else
                    { 
            <span>[@((i).ToString())]</span>
                    }
                }
            }
        }
        @if (ViewBag.PageIdx == ViewBag.PageCount - 1)
        {
            <span>下一页</span>
            <span>末页</span>
        
        }
        else
        {
            <span>@Html.ActionLink("下一页", "RecuperReport", new { qizSubjectID = ViewBag.Subject.ID, recuperID = ViewBag.RecuperID, pidx = ViewBag.PageIdx + 1 })
            </span>
            <span>@Html.ActionLink("末页", "RecuperReport", new { qizSubjectID = ViewBag.Subject.ID, recuperID = ViewBag.RecuperID, pidx = ViewBag.PageCount - 1 })
            </span>
        }
    </div>
    <script type="text/javascript">
//        $(function () {
//        });
    </script>
    
}